﻿using System;

namespace SharedGenomics.Annotations
{
    [Serializable]
    public class UriAnnotation : IAnnotation, IWebSearchable
    {
        #region Private Members

        private Uri _uri;
        private string _title;

        #endregion

        #region Constructors

        public UriAnnotation(Uri uri, string title)
        {
            _uri = uri;
            _title = title;
        }

        #endregion

        #region IWebSearchable Members

        public Uri SearchUri
        {
            get
            {
                return _uri;
            }
        }

        public string SummaryText
        {
            get { return _title ?? "<null>"; }
        }

        #endregion

        public AnnotationKey AnnotationKey
        {
            get { return AnnotationKey.Uri; }
        }

        public string Description
        {
            get { return _title ?? "<null>"; }
        }

        public string EncodedKey
        {
            get
            {
                return "<annotation type=\"Uri\"><url>" + System.Security.SecurityElement.Escape(SearchUri.ToString()) + "</url></annotation>";
            }
        }
    }
}
